<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2018/12/11
 * Time: 18:32
 */
namespace common\sources\read\category;

use common\models\craftsman\Category;

class CategoryAccess implements ICategoryAccess
{
    //获取父类列表
    public function getList()
    {
        return Category::find()
                ->select("id,name,pid,status")
                ->where(['pid' =>0])
                ->asArray()
                ->all();
    }
    //获取分类列表所有
    public function getAll($ids)
    {
        return Category::find()
                ->select("id,name,pid,status")
                ->where("pid in (".$ids.")")
                ->asArray()
                ->all();
    }
    //获取单个
    public function getCategory($cate_id)
    {
        return Category::find()
            ->select("id,name,pid,status")
            ->where("id = ".$cate_id."")
            ->asArray()
            ->all();
    }
}